table.insert(Assets, Asset("ATLAS", "images/hud/homura_tab.xml" ))

AddRecipe('homura_clock', {Ingredient('goldnugget',1), Ingredient('gears',1)
--[[, Ingredient(CHARACTER_INGREDIENT.SANITY, 15)]] }, 
RECIPETABS.MAGIC, TECH.NONE, nil, nil, nil, nil, nil,
'images/inventoryimages/homura_clock.xml', 'homura_clock.tex')

STRINGS.HOMURA_TAB = L and 'Munition' or '军火'

local HOMURA_TAB = AddRecipeTab( STRINGS.HOMURA_TAB, 999, "images/hud/homura_tab.xml", "homura_tab.tex", 'homura')
local NIL_TAB = AddRecipeTab('error', 1000, "images/hud/homura_tab.xml", "homura_tab.tex", 'lw_homura_no_tag') -- 注: 任何人都不应该拥有这个制造栏位

local Ig = Ingredient

AddRecipe("homura_workdesk",{Ig("gunpowder",2),Ig("log",8),Ig('goldnugget',4)}, HOMURA_TAB, TECH.SCIENCE_ONE,
'homura_workdesk_placer',2,nil,nil,nil,
"images/inventoryimages/homura_workdesk.xml", 
"homura_workdesk.tex")

local TECHLEVEL = {[1] = TECH.HOMURA_TECH_ONE, [2] = TECH.HOMURA_TECH_THREE}
local function AddModRecipe(prefab, ingredients, level, num, ...)
    return AddRecipe(prefab, ingredients, HOMURA_TAB, TECHLEVEL[level or 1], nil, nil, true, num, 'homura',
    "images/inventoryimages/"..prefab..".xml",
    prefab..".tex", ...)
end
local function AddHomuraBuff(buff, ingredients, level)
    local prefab = 'homura_weapon_buff_'..buff
    return AddRecipe(prefab, ingredients, HOMURA_TAB, TECHLEVEL[level or 1], nil, nil, true, nil, 'homura',
    "images/homura_weapon_buff.xml",
    prefab..".tex")
end

-- 2021.6.1
AddRecipe("homura_gunpowder_recipetab", {Ig("gunpowder", 4), Ig("powcake", 10), Ig("guano", 1)}, HOMURA_TAB, TECH.HOMURA_TECH_ONE,
    nil, nil, true, nil, "homura",
    "images/inventoryimages/homura_gunpowder.xml",
    "homura_gunpowder.tex")
AddRecipe("homura_gunpowder_1", {Ig("gunpowder", 4), Ig("guano", 1)}, NIL_TAB, TECH.LOST, nil, nil, true, 4).product = "homura_gunpowder"
AddRecipe("homura_gunpowder_2", {Ig("powcake", 10),  Ig("guano", 1)}, NIL_TAB, TECH.LOST, nil, nil, true, 4).product = "homura_gunpowder"

-- AddRecipe('homura_detonator_fake',{Ig('gunpowder',1),Ig('powcake',2),Ig('goldnugget',1)}, HOMURA_TAB, TECH.HOMURA_TECH_ONE,nil,nil,true,nil,'homura',
--     'images/inventoryimages/homura_detonator.xml',
--     'homura_detonator.tex')
-- AddRecipe('homura_detonator1',{Ig('gunpowder',1),Ig('goldnugget',1)},NIL_TAB, TECH.LOST,nil,nil,true,4,nil,nil,nil,nil,'homura_detonator')
-- AddRecipe('homura_detonator2',{Ig('powcake',2),Ig('goldnugget',1)},NIL_TAB, TECH.LOST,nil,nil,true,4,nil,nil,nil,nil,'homura_detonator')

local GUNPOWDER = function() return Ig('homura_gunpowder',1,'images/inventoryimages/homura_gunpowder.xml') end
local DETONATOR = function() return Ig('homura_detonator',1,'images/inventoryimages/homura_detonator.xml') end
AddModRecipe('homura_detonator', {GUNPOWDER(), Ig("goldnugget", 1)}, 1, 5) 
AddModRecipe('homura_bomb_bomb', {DETONATOR(), Ig('flint',4)})
AddModRecipe('homura_bomb_fire', {DETONATOR(), Ig('charcoal',3)})
AddModRecipe('homura_bomb_flash',{DETONATOR(), Ig('nitre',1)})

AddModRecipe('homura_rpg',{Ig('blowdart_fire',1), Ig('dragon_scales',1),Ig('homura_rpg_ammo1',1,'images/inventoryimages/homura_rpg_ammo1.xml')},2)
AddModRecipe('homura_rpg_ammo1',{DETONATOR(), Ig('log',4),Ig('durian',1)},2)

local AMMO1 = function(num) return Ig('homura_gun_ammo1',num,'images/inventoryimages/homura_gun_ammo1.xml') end
local BUFF = function(name) return Ig("homura_weapon_buff_"..name, 1, "images/homura_weapon_buff.xml") end

AddModRecipe('homura_pistol',   {Ig('blowdart_pipe',1),AMMO1(7)},1)
AddModRecipe('homura_gun',      {Ig('blowdart_pipe',1),Ig('walrus_tusk',1), AMMO1(20)},2)
-- 2021.6.1 删除机枪子弹
-- AddModRecipe('homura_hmg',{Ig('blowdart_pipe',1),Ig('gears',1), AMMO2(80)},2)
AddModRecipe('homura_hmg',      {Ig('blowdart_pipe',1),Ig('gears',2), AMMO1(80)},2)
AddModRecipe("homura_rifle",    {Ig("blowdart_pipe",1),BUFF("eye_lens"),AMMO1(5)}, 2)

AddModRecipe("homura_gun_ammo1", {GUNPOWDER(), Ig("goldnugget", 1)}, 1, 40)

-- AddModRecipe('homura_gun_ammo1',{Ig('gunpowder',1),Ig('goldnugget',2)},1,20)
-- AddModRecipe('homura_ammochain',{Ig('silk',4),Ig('rope',2)},2,1)
-- AddModRecipe('homura_gun_ammo2',{AMMO1(40),Ig('homura_ammochain',1,'images/inventoryimages/homura_ammochain.xml')},2,40)


table.foreach(
{
    lens    = {Ig('log',1),Ig('berries_cooked',1),Ig('bluegem',1)},
    knife   = {Ig('flint',10)},
    silent  = {Ig('heatrock',1),Ig('charcoal',2)},
    flyingspeed = {Ig('trinket_6',6),Ig('redgem',1),Ig('bluegem',1)},
},
function(k,v) AddHomuraBuff(k, v, 1) end)

table.foreach(
{
    ice     = {Ig('icehat',1),Ig('bluegem',3),Ig('gears',1)},
    code    = {Ig('beardhair',16)}, 
    magic   = {Ig('purplegem',4),Ig('nightmarefuel',6)},
    wind    = {Ig('feather_crow',6),Ig('feather_robin',6),Ig('feather_robin_winter',6)},
    waterproof  = {Ig('beeswax',1),Ig('pigskin',2)},
    mouse   = {Ig('cutreeds',29),BUFF("code"),Ig('goldnugget',1)},
    homing  = {BUFF("eye_lens"),Ig('boards',10),},
    eye_lens= {Ig('deerclops_eyeball',1),Ig('goldnugget',4),BUFF("lens")},
    clip    = {Ig('nightmarefuel',40),Ig('boards',2)},
    time    = {Ig('townportaltalisman',1), Ig('purplegem',1)},
    wormhole= {Ig("monstermeat",4), Ig("purplegem", 3), Ig("houndstooth", 5)},
    laser   = {Ig('moonrocknugget', 10)},
},
function(k,v) AddHomuraBuff(k, v, 2) end)

AddModRecipe('homura_wrench',{Ig('goldenaxe', 1),Ig('goldenpickaxe',1),Ig('goldenshovel',1)},1)